/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "ML.h"

/*#include "intern/DDPG/CDDPG包装.h"
#include "intern/DDPG/DDPG模型.h"
#include "intern/DDPG/DDPG外部调用PY.h"

#include <Python.h>



void f_initPython() {
	Py_SetPythonHome(L"C:/Users/44653/.conda/envs/mbt");
	//Py_SetPythonHome(L"C:/ProgramData/Anaconda3");


	Py_Initialize();
	// 检查初始化是否成功  
	if (!Py_IsInitialized()) {
		std::cout << "初始化失败" << std::endl;
		Py_Finalize();
	
		return;
	}
	
	int32 err = 0;
	err = PyRun_SimpleString("import sys");
	err = PyRun_SimpleString("import os");
	err = PyRun_SimpleString("sys.path.append('C:/Users/44653/.conda/envs/mbt/Lib')");
	err = PyRun_SimpleString("sys.path.append('C:/Users/44653/.conda/envs/mbt')");
	err = PyRun_SimpleString("sys.path.append('./')");
	//err = PyRun_SimpleString("import torch");

	//std::string path = "sys.path.append('D:/U/Project/节点/ML/intern/DDPG/')";
	std::string path = "sys.path.append('D:/U/')";
	PyRun_SimpleString(path.c_str());
	//auto a = PyRun_String(path.c_str(), 0, 0, 0);
	//err = PyRun_SimpleString("os.path.append('D:/U/Project/节点/ML/intern/DDPG/')");
	//Py_SetPythonHome(L"D:/U/Project/节点/ML/intern/DDPG/");
	auto* pModule1 = PyImport_ImportModule("numpy\0");//Python文件名 

}

void f_closePython() {
	Py_Finalize();
}



S_结构对象指针 f_createDDPG模型(uint32 输入维度, uint32 输出维度, uint8 e) {
	return f_createPyTorchDDPG模型(输入维度, 输出维度);

	std::string file = "pytorch_ddpg";
	return (S_结构对象指针) new S_DDPG调用Py(输入维度, 输出维度, file);

	return (S_结构对象指针) new S_Cddpg(输入维度, 输出维度);

}

S_结构对象指针 f_createMADDPG模型(uint32 输入维度, uint32 输出维度, uint8 e) {
	return S_结构对象指针();
}


std::vector<float32> f_预测动作(S_结构对象指针 net, std::vector<float32>& s, float32 探索率) {
	return f_PyTorch预测动作(net, s);

	S_Cddpg* model = (S_Cddpg*)net;
	return model->f_预测(s, 探索率);

}

void f_DDPG记录训练数据(S_结构对象指针 net, std::vector<float32>& s, std::vector<float32>& a, float32 r, std::vector<float32>& s下次, uint8 e) {
	f_PyTorchDDPG记录训练数据(net, s, a, r, s下次);
	return;

	S_Cddpg* model = (S_Cddpg*)net;
	model->f_add训练数据(s, a, r, s下次);
	return;
	
}

bool f_训练模型(S_结构对象指针 net, uint8 e) {
	return f_PyTorch训练模型(net);
	return false;

	S_Cddpg* model = (S_Cddpg*)net;
	model->f_训练();
	return false;
	
}*/




